
from enum import Enum, unique
from datetime import datetime


@unique
class PNEnum(Enum):
    Postive=1
    Negative=2
    Unknown=255
    
    @staticmethod
    def from_digit_str(d:str):
        return PNEnum(int(d))    

@unique
class ChoiceEnum(Enum):
    A:int=1
    B:int=2
    C:int=3
    D:int=4
    
    Unknown:int=255

    @staticmethod
    def from_digit_str(d:str):
        return ChoiceEnum(int(d))
@unique
class ScoreEnum(Enum):
    one=1
    two=2
    three=3
    four=4
    five=5
    
    @staticmethod
    def from_digit_str(d:str):
        return ScoreEnum(int(d))
    
Provinces=[
    "山西","辽宁省","吉林","黑龙江","江苏","浙江省","安徽","福建","江西","山东",
    "河南","湖北","湖南","广东","海南","四川","贵州","云南","陕西","甘肃","青海",
    "台湾","北京","天津","上海","重庆","内蒙古","广西","宁夏","新疆","西藏","香港","澳门"
]

ProvincesEncoding={e:i for i,e in enumerate(Provinces)}

Today=datetime(2022,10,10)

    
@unique    
class ProgramLanguage(Enum):
    C:int
    Cpp:int
    CSharp:int
    Java:int
    Python:int
    JavaScript:int
    Ruby:int
    Rust:int
    Others:int
    
def get_age(birth_date:datetime):
    year_dev=Today.year-birth_date.year
    month_dev=(Today.month-birth_date.month)/12
    
    if month_dev>0 and month_dev>=0.5:
        month_dev=1
    elif month_dev<0 and month_dev<=-0.5:
        month_dev=-1
    else:
        month_dev=0
        
    return year_dev+month_dev
    
    
    
def get_province_id(province:str):
    
    match_province=""
    for e in Provinces:
        if e in province:
            match_province=e
            break
    
    return ProvincesEncoding.get(match_province,-1)